import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:gameplay_flutter/lib_runtime/extension/string_extension/string_text.dart';

class SettingModel {
  final String title;
  final String icon;
  final bool isHomeOwner;

  const SettingModel({
    required this.title,
    required this.icon,
    this.isHomeOwner = false,
  });
}

List<SettingModel> settingModels = [
  const SettingModel(
    title: "Share",
    icon: "assets/images/room/room_setting_share.png",
  ),
  const SettingModel(
    title: "Edit",
    icon: "assets/images/room/room_setting_edit.png",
    isHomeOwner: true,
  ),
  const SettingModel(
    title: "Member",
    icon: "assets/images/room/room_setting_menber.png",
    isHomeOwner: true,
  ),
  const SettingModel(
    title: "Number",
    icon: "assets/images/room/room_setting_number.png",
    isHomeOwner: true,
  ),
  const SettingModel(
    title: "Wallpaper",
    icon: "assets/images/room/room_setting_wallpaper.png",
  ),
  const SettingModel(
    title: "Music",
    icon: "assets/images/room/room_setting_music.png",
  ),
  const SettingModel(
    title: "Privacy",
    icon: "assets/images/room/room_setting_privacy.png",
    isHomeOwner: true,
  ),
  const SettingModel(
    title: "Lock",
    icon: "assets/images/room/room_setting_lock.png",
    isHomeOwner: true,
  ),
  const SettingModel(
    title: "Public Screen",
    icon: "assets/images/room/room_setting_public_screen.png",
  ),
  const SettingModel(
    title: "Mode",
    icon: "assets/images/room/room_setting_mode.png",
    isHomeOwner: true,
  ),
  const SettingModel(
    title: "Ear Monitoring",
    icon: "assets/images/room/room_setting_ear_monitoring.png",
  ),
];

class RoomSetting extends StatelessWidget {
  const RoomSetting({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final count = settingModels.length;
    return IntrinsicHeight(
      child: SafeArea(
        child: Container(
          width: double.infinity,
          padding: EdgeInsetsDirectional.only(top: 17.h, start: 10.w, end: 10.w, bottom: 15.h),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              "Room Settings".text(
                fontSize: 22.sp,
                color: Colors.white,
                weight: TextFontWeight.medium,
              ),
              Wrap(
                children: settingModels.map((model) {
                  return SizedBox(
                    width: (1.sw-20.w) / 4, // 四列均分屏幕宽度
                    child: _buildSettingItem(model),
                  );
                }).toList(),
              )
            ],
          ),
        ),
      ),
    );
  }

  Widget _buildSettingItem(SettingModel model) {
    return Container(
        padding: EdgeInsets.symmetric(vertical: 10.h),
        child: Column(children: [
          Image.asset(
            model.icon,
            width: 48.w,
            height: 48.h,
          ),
          SizedBox(
            width: 13.w,
          ),
          model.title.text(
            fontSize: 12.sp,
            color: const Color(0xFFCACACA),
          )
        ]));
  }
}
